package com.hjq.fcloud.utils

import android.app.Activity
import com.github.gzuliyujiang.wheelpicker.DatePicker
import com.github.gzuliyujiang.wheelpicker.annotation.DateMode
import com.github.gzuliyujiang.wheelpicker.widget.DateWheelLayout

/**
 * 时间选择
 */
object CommonTimeSelectUtils {

    /**
     * 年月日选择
     */
    fun showYMD(activity: Activity, callback: (String) -> Unit): DateWheelLayout {
        val picker = DatePicker(activity)
        val wheelLayout = picker.wheelLayout
        picker.setOnDatePickedListener { year, month, day ->
            var text = "$year-$month-$day"
            callback(text)
        }
        wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY)
        wheelLayout.setDateLabel("年", "月", "日")
        picker.show()
        return wheelLayout
    }
}